# coding = utf-8


def get_db_uri(dbinfo):
    engine = dbinfo.get('ENGINE') or 'sqlite'
    driver = dbinfo.get('DRIVER') or 'sqlite'
    user = dbinfo.get('USER') or ''
    password = dbinfo.get('PASSWORD') or ''
    host = dbinfo.get('HOST') or ''
    port = dbinfo.get('PORT') or ''
    name = dbinfo.get('NAME') or ''
    uri = f'{engine}+{driver}://{user}:{password}@{host}:{port}/{name}'
    return uri


class Config:
    DEBUG = False
    TESTING = False
    SQLALCHEMY_TRACK_MODIFICATIONS = False


# 开发环境
class DevelopConfig(Config):
    DEBUG = True

    dbinfo = {
        'ENGINE': 'mysql',
        'DRIVER': 'pymysql',
        'USER': 'root',
        'PASSWORD': '1234qwer',
        'HOST': 'localhost',
        'PORT': '3306',
        'NAME': 'testmysql'
    }
    SQLALCHEMY_DATABASE_URI = get_db_uri(dbinfo)
    UPLOADED_PHOTOS_DEST = 'E:\\FlaskLearning\\NEWFlask\\upload'
    UPLOADED_PHOTOS_ALLOW = {'png', 'jpg', 'jpeg', 'gif'}
    SECRET_KEY = '123456'  # 密钥
    SESSION_TYPE = 'redis'
    UPLOAD_FOLDER="upload"

envs = {
    "develop": DevelopConfig,
}
